package edu.uwlax.cs.oayonlinestore.server;

import java.util.Date;

import javax.servlet.http.HttpSession;

import edu.uwlax.cs.oayonlinestore.vo.UserDetailsVO;

public class Session {

	public final static String KEY = "QAY_SESSION";

	private static OnlinestoreRServiceImpl service;

	public static Session get() {
		HttpSession http = service.getHTTPRequest().getSession();
		Session s = (Session) http.getAttribute(KEY);
		if (s == null)
			http.setAttribute(KEY, s = new Session());
		return s;
	}

	static void setService(OnlinestoreRServiceImpl aService) {
		service = aService;
	}

	private int orderID = 0;

	private UserDetailsVO user;

	public Session() {
		super();
		resetUser();
	}

	public int getOrderID() {
		return orderID;
	}

	public UserDetailsVO getUser() {
		return user;
	}

	public void resetUser() {
		user = new UserDetailsVO(0, "", "", true, "", "", "", "", "", "", 0,
				"", "", "", new Date(), false, false, false, false, true, false);
	}

	public void setOrderID(int orderID) {
		this.orderID = orderID;
	}

	public void setUser(UserDetailsVO user) {
		this.user = user;
	}

}
